import request from "@/utils/request";
import type { CategoryResponseData, AttrResponseData, Attr } from './type'

enum API {
    // 获取一级分类接口地址
    C1_URL = '/category?category_level=1',
    // 获取二级分类接口地址
    C2_URL = '/category?category_level=2&category_parent_id=',
    // 获取三级分类接口地址
    C3_URL = '/category?category_level=3&category_parent_id=',
    // 获取分类下已有属性与属性值
    ATTR_URL = '/admin/product/attrInfoList/',
}

export const reqC1 = () => {
    return request.get<any, CategoryResponseData>(API.C1_URL)
}

export const reqC2 = (category1Id: number | string) => {
    return request.get<any, CategoryResponseData>(API.C2_URL + category1Id)
}

export const reqC3 = (category2Id: number | string) => {
    return request.get<any, CategoryResponseData>(API.C3_URL + category2Id)
}

export const reqAttr = (category1Id: number | string, category2Id: number | string, category3Id: number | string) => {
    return request.get<any, AttrResponseData>(API.ATTR_URL + `${category1Id}/${category2Id}/${category3Id}`,)
}